package com.example.mq.mqclient;

import java.io.IOException;

public class ConnectionFactory {

    private String host;

    private int port;

    // 访问 broker server 的哪个虚拟主机
    private String virtualHostName = "default";
//    private String username;
//    private String password;

    public Connection newConnection() throws IOException {
        Connection connection = new Connection(host, port, virtualHostName);
        return connection;
    }

    public Connection newConnection(String virtualHostName) throws IOException {
        Connection connection = new Connection(host, port, virtualHostName);
        return connection;
    }

    public String getHost() {
        return host;
    }

    public void setHost(String host) {
        this.host = host;
    }

    public int getPort() {
        return port;
    }

    public void setPort(int port) {
        this.port = port;
    }
    
    public String getVirtualHostName() {
        return virtualHostName;
    }

    public void setVirtualHostName(String virtualHostName) {
        if (virtualHostName != null && !virtualHostName.isEmpty()) {
            this.virtualHostName = virtualHostName;
        }
    }
}
